class Solution
{
public:
    int arithmeticTriplets(vector<int> &nums, int diff)
    {
        unordered_set<int> s(nums.begin(), nums.end());
        int tripleCount = 0;
        for (int num : s)
        {
            if (s.count(num + diff) && s.count(num + 2 * diff))
            {
                ++tripleCount;
            }
        }
        return tripleCount;
    }
};